package com.power.sifa.approve.dao;

import com.power.sifa.approve.model.Apl_arrive_material;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;

/**
 * 送达记录文书材料 持久层(hibernate)
 */

public interface Apl_arrive_materialDao extends JpaRepository<Apl_arrive_material, Serializable>, JpaSpecificationExecutor<Apl_arrive_material>, Repository<Apl_arrive_material, Serializable>, Apl_arrive_materialDaoCustom<Apl_arrive_material, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Apl_arrive_material s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   /**
    * 通过送达详情记录的iD查询对应的材料信息
    * @param recordIds
    * @return
    */
   @Query("from Apl_arrive_material s where s.recordid in (:recordIds) ")
   List<Apl_arrive_material> findMaterialsByRecordIds(@Param("recordIds") List<String> recordIds);

   /**
    * 通过送达详情记录删除对应的材料信息
    * @param recordIds
    */
   @Modifying
   @Transactional
   @Query("delete from Apl_arrive_material s where  s.recordid in (:recordIds) ")
   void removeByRecordIds(@Param("recordIds") List<String> recordIds);
}
